package com.qiang.testspecialview;

import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;

public class MainActivity extends Activity implements RegularHexagonView.OnSelectedListener{

    private RegularHexagonLayout layout;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        layout = (RegularHexagonLayout) findViewById(R.id.specail_view);

        //可以动态的给某个正六边形设置文本.
        RegularHexagonView childAt = (RegularHexagonView) layout.getChildAt(0);
        childAt.setDrawText("综合评价");


        //给所有正六边形设置单击事件.
        for(int i=0;i<layout.getChildCount();i++){
            RegularHexagonView child = (RegularHexagonView) layout.getChildAt(i);
            child.setOnSelectedListener(this);
        }
    }



    @Override
    public void onSelected(RegularHexagonView view, int index) {
        Toast.makeText(this,"index:" + index,Toast.LENGTH_SHORT).show();
    }
}
